<template>
    <div>
        <button @click="getALoveSentence">获取一句土味情话</button>
        <ul>
            <li v-for=" l in talkStore.talkList " :key="l.id">
                {{ l.content }}
            </li>
        </ul>
    </div>
</template>

<script setup lang="ts">
import { reactive } from 'vue';
import axios from 'axios';
import { useTalksStore } from '@/store/talks';

//生成随机id
import { nanoid } from 'nanoid'

const talkStore = useTalksStore()

// const loveList = reactive([
//     { id: 'dasdadasddsada001', content: '你今天有点怪，哪里怪？怪好看的！' },
//     { id: 'dasdadasddsada002', content: '草莓、蓝莓、蔓越莓，你想我了没？' },
//     { id: 'dasdadasddsada003', content: '心里给你留了一块地，我的死心塌地' }
// ])

async function getALoveSentence() {
    // //    let  res =  await axios.get('https://api.uomg.com/api/rand.qinghua?format=json');

    // //解构做法
    // //    let {data} = await axios.get('https://api.uomg.com/api/rand.qinghua?format=json');
    // //解构 再解构做法
    // let { data: { content } } = await axios.get('https://api.uomg.com/api/rand.qinghua?format=json');
    // console.log(content)
    // // 组装成对象

    // let obj = { id: nanoid(), content: content }
    // //将对象压入列表 从上往下
    // loveList.unshift(obj)
    talkStore.getImg()
}
</script>

<style scoped></style>